/*
 * @Author       : 骇熊的锅
 * @Date         : 2024-08-03 21:35:40
 * @LastEditTime : 2024-08-03 22:27:24
 * @Description  : 
 */


/**
 * @description: 
 */
let data = [
    { id: 1, name: "Alice" },
    { id: 2, name: "Bob" },
    { id: 3, name: "Charlie" },
    { id: 4, name: "Dave" }
]
const repeatId = [2, 3];
const filterList = data.filter(row =>
    !repeatId.includes(row["id"])
)
console.log("🚀 ~ filterList:", filterList)

/* function fuzzySearch(arr, query) {
    return arr.filter(item => {
        let workTicket = item['1001718821844836355']?.content || "";
        let workTicketType = item['1003638642077491201']?.content || "";
        return workTicket.includes(query["工作票号"]) && workTicketType.includes(query["工作票类型"]) 
    });
} */
/**
 * @description: 封装本地搜索
 * @param {type} arr
 * @param {type} query
 */
function fuzzySearch(arr, query) {
    return arr.filter(item => {
        return fields.every(field => {
            const fieldValue = item[field.name] || "";
            const queryValue = query[field.name] || "";
            return fieldValue.includes(queryValue);
        });
    });
}
const arr = [
    { name: "Alice", age: 25, majorName: "语文" },
    { name: "Bob", age: 30, majorName: "化学" },
    { name: "名字1", age: 35, majorName: "化学" },
    { name: "Dave", age: 40, majorName: "数学" }
];
const fields = [
    { label: '名称', name: 'name', placeholder: '搜索名称' },
    { label: '专业', name: 'majorName', placeholder: '搜索专业' },
];
const query = { name: "名字1", majorName: "化学" };
const results = fuzzySearch(arr, query);
console.log("🚀 ~ results:", results)
/* (<Row gutter={[20, 10]}>
    {fields.map((field, index) => (
        <Col className="layoutboxcol" key={index}>
            <span>{field.label}</span>
            <Input
                value={search[field.name]}
                onChange={this.handleChange}
                onPressEnter={this.onPressEnter}
                placeholder={field.placeholder}
                name={field.name}
            />
        </Col>
    ))}
</Row>) */